# +----------------------------------------------------------------------------+
# | Copyright (C)2001-2006 Altera Corporation                                  |
# |  Any megafunction design, and related net list (encrypted or decrypted),   |
# |  support information, device programming or simulation file, and any other |
# |  associated documentation or information provided by Altera or a partner   |
# |  under Altera's Megafunction Partnership Program may be used only to       |
# |  program PLD devices (but not masked PLD devices) from Altera.  Any other  |
# |  use of such megafunction design, net list, support information, device    |
# |  programming or simulation file, or any other related documentation or     |
# |  information is prohibited for any other purpose, including, but not       |
# |  limited to modification, reverse engineering, de-compiling, or use with   |
# |  any other silicon devices, unless such use is explicitly licensed under   |
# |  a separate agreement with Altera or a megafunction partner.  Title to     |
# |  the intellectual property, including patents, copyrights, trademarks,     |
# |  trade secrets, or maskworks, embodied in any such megafunction design,    |
# |  net list, support information, device programming or simulation file, or  |
# |  any other related documentation or information provided by Altera or a    |
# |  megafunction partner, remains with Altera, the megafunction partner, or   |
# |  their respective licensors.  No other licenses, including any licenses    |
# |  needed under any third party's intellectual property, are provided herein.|
# |  Copying or modifying any file, or portion thereof, to which this notice   |
# |  is attached violates this copyright.                                      |
# +----------------------------------------------------------------------------+




# +----------------------------------------------------------------------------+
# | file: UP_Extras.pm                                                         |
# |                                                                            |
# | This SOPC Builder Generator program is provided by                         |
# | Altera's University Program.                                               |
# |                                                                            |
# | Its contains miscellaneous subroutines                                     |
# | used by the UP Core Generator package                                      |
# |                                                                            |
# | version: 0.4                                                               |
# |                                                                            |
# +----------------------------------------------------------------------------+

package UP_Extras;
use Exporter;


@ISA = Exporter;
@EXPORT = qw(
	copy_additional_files
);


use strict;
use filename_utils;
use UP_System_Info;
use UP_PTF_Parser;


sub copy_additional_files
{
	my ($error, @additional_files) = get_addition_files();
	return $error if ($error != 1);

	my $file_count	= $#additional_files + 1;

	my $source_dir	= get_ip_core_directory();
	my $dest_dir	= get_system_directory();

	if ($file_count > 0)
	{

		opendir (SDIR, $source_dir)	or return "can't open $source_dir !";
		opendir (DDIR, $dest_dir)	or return "can't open $dest_dir !";

		for(my $i = 0; $i < $file_count; $i++)
		{
			my $current_file_name	= $additional_files[$i];
			my $source_subdir		= "/";
			my $source_filename		= $current_file_name;

			if ($current_file_name		=~ /\//)
			{
				$source_subdir		= "/".$`."/";
				$source_filename	= $';
			}

			my $source_fullpath		= "$source_dir$source_subdir$source_filename";
			my $dest_fullpath		= "$dest_dir/$source_filename";

			Perlcopy($source_fullpath, $dest_fullpath);
		}

		closedir (SDIR);
		closedir (DDIR);

	}

	return 1;
}

# End with success

return 1;

# end of file

